﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using FG_Admin_DAL;

namespace FG_Admin_DAL
{
    public class VideosDAL
    {
        FGSkiingEntities model = new FGSkiingEntities();
        /// <summary>
        /// 返回所有的视频信息
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        public List<Videos> GetVideos(int PageIndex,int PageSize)
        {
            return model.Videos.OrderBy(p=>p.Videos_ID).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
        }
        /// <summary>
        /// 返回对应类别的视频
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="Videos_Type">视频类别</param>
        /// <returns></returns>
        public List<Videos> GetVideos(int PageIndex, int PageSize,int Videos_Type)
        {
            return model.Videos.Where(p => p.Videos_Type == Videos_Type).OrderBy(p=>p.Videos_ID).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
        }
        /// <summary>
        /// 添加视频
        /// </summary>
        /// <param name="ss">视频对象</param>
        /// <returns></returns>
        public int AddVideos(Videos ss)
        {
            model.Videos.Add(ss);
            return model.SaveChanges();
        }
        /// <summary>
        /// 删除对应的视频
        /// </summary>
        /// <param name="VideosID">视频编号</param>
        /// <returns></returns>
        public int DelVideos(int VideosID)
        {
            model.Videos.Remove(model.Videos.Where(p => p.Videos_ID == VideosID).FirstOrDefault());
            return model.SaveChanges();
        }
    }
}
